﻿using ControleRepresentante.Data.Catalogs;
using ControleRepresentante.Data.Helpers;

namespace ControleRepresentante.Data.CatalogSteps
{
    internal class PedidoCreationAndModifiedDates : CatalogStepBase<ControleRepresentanteCatalogStepTypes>
    {
        protected override ControleRepresentanteCatalogStepTypes CatalogStepType
        {
            get { return ControleRepresentanteCatalogStepTypes.PedidoCreationAndModifiedDates; }
        }

        public override void Execute(IDataAccess dataAccess)
        {
            new CatalogStepHelper(dataAccess)
                .GetTable("Pedido")
                    .AddColumn("Created", ColumnType.DateTime, false, false)
                    .AddColumn("Modified", ColumnType.DateTime, false, false);

            dataAccess.ExecuteCommand(@"
                UPDATE Pedido
                SET
                    Created = Data,
                    Modified = Data");
        }
    }
}
